<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.Calendar.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.Date" %>
<% String description=request.getParameter("description"); 
String heading=request.getParameter("heading");         
  String name=request.getParameter("name");
         %>   
            
    <%
    Calendar calendar = Calendar.getInstance();
    %>        
      
          <% //connect to database and set emp_id to the session
            int year=calendar.get(Calendar.YEAR);
            int month=calendar.get(Calendar.MONTH)+1;
            int day=calendar.get(Calendar.DAY_OF_MONTH);
            String query="insert into forumreply (heading,description,name,date) values ('"+heading+"','"+description+"','"+name+"','"+year+"-"+month+"-"+day+"')";
              
             
            String query1="update forumpost set replies=(replies+1) where heading='"+heading+"'";
            Connection db_conn = null;
            Statement statement = null;
            PreparedStatement pstmt;
            ResultSet rs;
            try{
            Class.forName("com.mysql.jdbc.Driver");
            String url= "jdbc:mysql://localhost:3306/db";
            db_conn = DriverManager.getConnection( url,"root", "root" );
            statement = db_conn.createStatement();  
            statement.executeUpdate(query);
            statement.executeUpdate(query1);
            db_conn.close();
            }
            catch(SQLException e){
            e.printStackTrace();
            out.println("sql not found");
            out.println(e);
            }
            catch(ClassNotFoundException e){
            e.printStackTrace();
            out.println(e);
            }
            %>






